{% extends "base.html" %}

{% block main %}

<form action="{{url_for('batch_operation')}}" method="post" class="pt-3">
    <input type="hidden" name="p" value="{{folder_path}}">
    <input type="hidden" name="group" value="1">
    <div class="table-responsive">
        <table class="table table-bordered table-hover table-sm bg-white" id="main-table">
            <thead class="thead-white">
            <tr>
                <th style="width:3%" class="custom-checkbox-header">
                    <div class="custom-control custom-checkbox">
                        <input type="checkbox" class="custom-control-input" id="js-select-all-items" onclick="checkbox_toggle()">
                        <label class="custom-control-label" for="js-select-all-items"></label>
                    </div>
                </th>
                <th>Name</th>
                <th>Size</th>
                <th>Modified</th>
                <th>Perms</th>
                <th>Owner</th>
                <th>Actions</th>
            </tr>
            </thead>
            
            {% if parent_folder %}
                <tr>
                    <td class="nosort"></td>
                    <td class="border-0"><a href="{{url_for('main', path=parent_folder)}}"><i class="fa fa-chevron-circle-left go-back"></i> ..</a></td>
                    <td class="border-0"></td>
                    <td class="border-0"></td>
                    <td class="border-0"></td>
                    <td class="border-0"></td>
                    <td class="border-0"></td>
                </tr>
            {% endif %}

{% for folder in folders %}
<tr>
    <td class="custom-checkbox-td">
    <div class="custom-control custom-checkbox">
        <input type="checkbox" class="custom-control-input" id="{{folder['ii']}}" name="file[]" value="{{folder['name']}}">
        <label class="custom-control-label" for="{{folder['ii']}}"></label>
    </div>
    </td>
    <td>
        <div class="filename"><a href="{{url_for('main', path=folder['path'])}}">
        <i class="fa fa-folder-o"></i> {{folder['name']}}
            </a>{%if folder['is_symlink']%} &rarr; <i>{{folder['symlink_to']}}</i> {%endif%}
    </td>
    <td data-sort="a-{{folder['size']}}">
        {{folder['size_str']}}
    </td>
    <td data-sort="a-{{folder['modified_time']}}">{{folder['modified_time_str']}}</td>
    <td>{{folder['permission']}}</td>
    <td>{{folder['owner']}}</td>
    <td class="inline-actions">
        <a title="Delete" href="{{url_for('delete', path=folder['path'])}}" onclick="return confirm('Delete folder {{folder['name']}} ?');"> <i class="fa fa-trash-o" aria-hidden="true"></i></a>
        <a title="Rename" href="{{url_for('rename', path=folder['path'])}}" onclick="rename('{{folder['path']}}', '{{folder['name']}}');return false;"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></a>
        <a title="Copy / Move" href="{{url_for('copymove', path=folder['path'])}}"><i class="fa fa-files-o" aria-hidden="true"></i></a>
    </td>
</tr>
{% endfor %}


{% for file in files %}
<tr>
    <td class="custom-checkbox-td">
    <div class="custom-control custom-checkbox">
        <input type="checkbox" class="custom-control-input" id="{{file['ik']}}" name="file[]" value="{{file['name']}}">
        <label class="custom-control-label" for="{{file['ik']}}"></label>
    </div>
    </td>
    <td>
        <div class="filename">
            <a href="{{url_for('main', path=file['path'])}}" title="{{file['name']}}">
                <i class="{{file['icon_class']}}"></i> {{file['name']}}
            </a>{%if file['is_symlink']%} &rarr; <i>{{file['symlink_to']}}</i> {%endif%}
        </div>
    </td>
    <td data-sort="b-{{file['size']}}"><span title="{{file['size']}} bytes">
        {{file['size_str']}}
        </span></td>
    <td data-sort="b-{{file['modified_time']}}">{{file['modified_time_str']}}</td>
    <td>{{file['permission']}}</td>
    <td>{{file['owner']}}</td>
    <td class="inline-actions">
            <a title="Delete" href="{{url_for('delete', path=file['path'])}}" onclick="return confirm('Delete file {{file['name']}} ?');"> <i class="fa fa-trash-o"></i></a>
            <a title="Rename" href="{{url_for('rename', path=file['path'])}}" onclick="rename('{{file['path']}}', '{{file['name']}}');return false;"><i class="fa fa-pencil-square-o"></i></a>
            <a title="Copy / Move"
                href="{{url_for('copymove', path=file['path'])}}"><i class="fa fa-files-o"></i></a>
        <a title="Download" href="{{url_for('main', path=file['path'])}}"><i class="fa fa-download"></i></a>
    </td>
</tr>
{% endfor %}
            
<tfoot>
    <tr>
        <td class="gray" colspan="6">
            Full Size: <span class="badge badge-light">{{total_size}}</span>
            File: <span class="badge badge-light">{{file_num}}</span>
            Folder: <span class="badge badge-light">{{folder_num}}</span>

            Partition Size: (
            <span class="badge badge-light">{{disk_total_size}}</span>  Total,
            <span class="badge badge-light">{{disk_used_size}}</span> Used,
            <span class="badge badge-light">{{disk_free_size}}</span> Free )
        </td>
    </tr>
</tfoot>
</table>
</div>

<div class="row">
    <div class="col-xs-12 col-sm-9">
        <ul class="list-inline footer-action">
            <li class="list-inline-item"> <a href="#/select-all" class="btn btn-small btn-outline-primary btn-2" onclick="select_all();return false;"><i class="fa fa-check-square"></i> Select All </a></li>
            <li class="list-inline-item"><a href="#/unselect-all" class="btn btn-small btn-outline-primary btn-2" onclick="unselect_all();return false;"><i class="fa fa-window-close"></i> UnSelect All </a></li>
            <li class="list-inline-item"><a href="#/invert-all" class="btn btn-small btn-outline-primary btn-2" onclick="invert_all();return false;"><i class="fa fa-th-list"></i> Invert Selection </a></li>
            <li class="list-inline-item"><input type="submit" class="hidden" name="delete" id="a-delete" value="delete" onclick="return confirm('Delete selected files and folders?')">
                <a href="javascript:document.getElementById('a-delete').click();" class="btn btn-small btn-outline-primary btn-2"><i class="fa fa-trash"></i> Delete </a></li>
            <li class="list-inline-item"><input type="submit" class="hidden" name="copy" id="a-copy" value="copy">
                <a href="javascript:document.getElementById('a-copy').click();" class="btn btn-small btn-outline-primary btn-2"><i class="fa fa-files-o"></i> Copy / Move </a></li>
        </ul>
    </div>
    <div class="col-3 d-none d-sm-block"><a href="https://tinyfilemanager.github.io" target="_blank" class="float-right text-muted">TinyFileManager-Py</a></div>
</div>

</form>

{% endblock %}